package com.ccoffers.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.ccoffers.model.shopping.Merchant;
import com.ccoffers.service.impl.CRUDServiceImpl;

@Controller
@RequestMapping(value="/merchant")
public class MerchantNameAdminController {
	@Autowired
	private CRUDServiceImpl<Merchant> merchantNameService;

	@RequestMapping(value="/add")
	public String addMerchantName(@RequestParam("merchantName") String merchantName,
			Model model) {
		Merchant merchant = new Merchant();
		merchant.setMerchantName(merchantName);
		merchantNameService.update(merchant);
		return "redirect:/internal/admin";
	}
	
	@RequestMapping(value="/delete")
	public String deleteCreditCardCompany(@RequestParam("id") Long id, Model model){
		merchantNameService.delete(merchantNameService.retrieve(Merchant.class, id));
		return "redirect:/internal/admin";
	}
}
